<?php

/**
 * Product form base class.
 *
 * @method Product getObject() Returns the current form's model object
 *
 * @package    sf_sandbox
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseProductForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_product'             => new sfWidgetFormInputHidden(),
      'id_user'                => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => false)),
      'id_category'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Category'), 'add_empty' => false)),
      'id_subcategory'         => new sfWidgetFormInputText(),
      'id_producer'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Producer'), 'add_empty' => false)),
      'name_product'           => new sfWidgetFormInputText(),
      'upc_product'            => new sfWidgetFormInputText(),
      'price'                  => new sfWidgetFormInputText(),
      'quantity'               => new sfWidgetFormInputText(),
      'image'                  => new sfWidgetFormInputText(),
      'description'            => new sfWidgetFormTextarea(),
      'devasin'                => new sfWidgetFormInputText(),
      'price_secure_transport' => new sfWidgetFormInputText(),
      'number_libras'          => new sfWidgetFormInputText(),
      'price_libras'           => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id_product'             => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_product')), 'empty_value' => $this->getObject()->get('id_product'), 'required' => false)),
      'id_user'                => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('User'))),
      'id_category'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Category'))),
      'id_subcategory'         => new sfValidatorInteger(),
      'id_producer'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Producer'))),
      'name_product'           => new sfValidatorString(array('max_length' => 150)),
      'upc_product'            => new sfValidatorInteger(),
      'price'                  => new sfValidatorNumber(),
      'quantity'               => new sfValidatorInteger(),
      'image'                  => new sfValidatorString(array('max_length' => 100)),
      'description'            => new sfValidatorString(),
      'devasin'                => new sfValidatorInteger(),
      'price_secure_transport' => new sfValidatorNumber(),
      'number_libras'          => new sfValidatorInteger(),
      'price_libras'           => new sfValidatorNumber(),
    ));

    $this->widgetSchema->setNameFormat('product[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Product';
  }

}
